﻿using System;
using System.Text;
using System.Collections;
using System.IO;
using System.Globalization;
using System.Reflection;
using System.Collections.Generic;

namespace RAP.Framework.Libary.Utils
{
    /// <summary>
    /// 
    /// </summary>
    public static partial class Extensions
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="target"></param>
        /// <param name="attrType"></param>
        /// <param name="inherit"></param>
        /// <returns></returns>
        public static bool HasAttribute( this MemberInfo target, Type attrType, bool inherit = true )
        {
            return target.GetCustomAttribute( attrType, inherit ) != null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="target"></param>
        /// <param name="inherit"></param>
        /// <returns></returns>
        public static bool HasAttribute<T>( this MemberInfo target, bool inherit = true ) where T : Attribute
        {
            return target.GetCustomAttribute<T>( inherit ) != null;
        }
    }
}
